import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class TrocaParametro {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		File f = new File("./");
		
		for (File l : f.listFiles()) {
			
			if (l.isDirectory()) { // itera pelos cenarios
				
				for (File k : l.listFiles()) {
					
					if (k.isDirectory()) { // itera pelas fontes
						
						for (File s: k.listFiles()) {
							
							if (s.isDirectory()) { // itera pelas pausas
								
								for (File r : s.listFiles()) {
									
									if (r.isDirectory()) { // itera pelas sementes
										
										trocaParametroNodePlacement(r);
									}
								}
							}
						}					
					}
				}				
			}
		}
	}
	
	private static void trocaParametroNodePlacement(File pastaSeed) throws IOException {
		
		File configinOrig = new  File(pastaSeed, "config.in");
	
		BufferedReader in = new BufferedReader(new FileReader(configinOrig));
				
		String linha = "";
		StringBuilder sb = new StringBuilder();
		
		while ((linha = in.readLine()) != null) {
			
			if (linha.equals("NODE-PLACEMENT      RANDOM")) {
				linha = "# NODE-PLACEMENT      RANDOM";
			}
			else {
				if (linha.equals("# NODE-PLACEMENT      UNIFORM")) {
					linha = "NODE-PLACEMENT      UNIFORM";
				}
			}
			
			sb.append(linha + "\n");			
		}
		
		in.close();
		
		File configinDest = new  File(pastaSeed, "config.in");
		BufferedWriter out = new BufferedWriter(new FileWriter(configinDest));
		
		out.write(sb.toString());				
		
		out.flush();
		out.close();
	}
}